using System;
using UnityEngine;

namespace Events
{
    [CreateAssetMenu(fileName = "New Event", menuName = "Events/Void Event", order = 0)]
    public class VoidEventChannel : ScriptableObject
    {
        public event Action Raised;

        [SerializeField] private bool fireOnlyOnce = false;

        private bool _fired;

        
        public void Raise()
        {
#if !UNITY_EDITOR
            if (_fired && fireOnlyOnce)
            {
                return;
            }
#endif

            _fired = true;
            
            Raised?.Invoke();
        }

        public void Init()
        {
            _fired = false;
        }
    }
}